﻿namespace _4.Native_SQL_Query
{
	using System;
	using System.Linq;

	using _1.Maping_all_tables_in_DB_First;

	class Main_Task4
	{
		static void Main()
		{
			/* Find all employees who have projects with start date in the year 2002. Select only their first name.
			 * Solve this task by using both LINQ query and native SQL query through the context.
			 */

			using (var databaseContext = new SoftUniEntities())
			{
				var query =
					@"
						SELECT e.FirstName
							FROM Employees e
						INNER JOIN EmployeesProjects ep 
							ON ep.EmployeeID = e.EmployeeID
						INNER JOIN Projects p 
							ON p.ProjectID = ep.ProjectID
						WHERE YEAR(p.StartDate) = 2002
					";

				var employees = context.Database.SqlQuery<List<string>>(query).ToList();
			}
		}
	}
}